------------------------------------- VARIABLES ---------------------------------------
SLIB_NOM = "插件命令控制台";
SLIB_VERS = "1.0";

------------- valeurs par defaut
SlashLibSaved = {};
SlashLibSaved["closeRun"] = false;

SlashLibSavedData = {};
SlashLibSavedData[1] = {"[插件整合]小地图收纳按钮","/mbf",1};
SlashLibSavedData[2] = {"[插件整合]插件命令控制台","/cj",1};
SlashLibSavedData[3] = {"[插件整合]插件控制面板","/mcp",1};
SlashLibSavedData[4] = {"[地图]显示飞行地图","/fmap",1};
SlashLibSavedData[5] = {"[辅助]交易通告","/stg",1};
SlashLibSavedData[6] = {"[辅助]人口普查","/census",1};
SlashLibSavedData[7] = {"[辅助]任务对话体验","/storyline",1};
SlashLibSavedData[8] = {"[辅助]VG任务导航","/vg toggle",1};
SlashLibSavedData[9] = {"[辅助]任务进度通告","/qa",1};
SlashLibSavedData[10] = {"[辅助]任务进度通告","/fq",1};
SlashLibSavedData[11] = {"[辅助]天赋保存切换","/ts",1};
SlashLibSavedData[12] = {"[辅助]广告垃圾关键词屏蔽","/ignoreplayer",1};
SlashLibSavedData[13] = {"[辅助]战斗距离","/dw",1};
SlashLibSavedData[14] = {"[辅助]法术计时器","/Chronometer",1};
SlashLibSavedData[15] = {"[辅助]私聊窗口","/wim",1};
SlashLibSavedData[16] = {"[辅助]简单自我施法","/scastself",1};
SlashLibSavedData[17] = {"[辅助]精英侦测","/sd",1};
SlashLibSavedData[18] = {"[辅助]网格界面对齐","/ba",1};
SlashLibSavedData[19] = {"[辅助]聊天辅助","/chatmod",1};
SlashLibSavedData[20] = {"[辅助]聊天辅助","/cleanchat",1};
SlashLibSavedData[21] = {"[辅助]自动Buff","/ab",1};
SlashLibSavedData[22] = {"[辅助]自动卖垃圾","/ap",1};
SlashLibSavedData[23] = {"[辅助]饰品技能爆发","/tt",1};
SlashLibSavedData[24] = {"[辅助]懒猪","/Lazypig",1};
SlashLibSavedData[25] = {"[辅助]秒表[显示]","/stw show",1};
SlashLibSavedData[26] = {"[辅助]秒表[隐藏]","/stw hide",1};
SlashLibSavedData[27] = {"[辅助]消耗品助手","/autobar",1};
SlashLibSavedData[28] = {"[辅助]先进的武器","/adws",1};
SlashLibSavedData[29] = {"[辅助]一键换装-PVP装备速换","/gearmenu opt",1};
SlashLibSavedData[30] = {"[界面]一键换装-装备槽助手","/equipslot",1};
SlashLibSavedData[31] = {"[辅助]ROLL点美化","/smrf",1};
SlashLibSavedData[32] = {"[界面]动作距离显示","/rc",1};
SlashLibSavedData[33] = {"[界面]怪物数据库","/mi2",1};
SlashLibSavedData[34] = {"[界面]技能冷却个性显示","/cdp",1};
SlashLibSavedData[35] = {"[界面]施法条美化","/punsch config",1};
SlashLibSavedData[36] = {"[界面]炽火动作条","/zbar",1};
SlashLibSavedData[37] = {"[界面]露娜头框架","/luf menu",1};
SlashLibSavedData[38] = {"[界面]Lua错误报告","/error",1};
SlashLibSavedData[39] = {"[界面]界面部件移动","/move",1};
SlashLibSavedData[40] = {"[界面]动作条技能冷却计时","/cc",1};
SlashLibSavedData[41] = {"[界面]动作条技能冷却计时","/omnicc",1};
SlashLibSavedData[42] = {"[界面]Shagu颜色","/scol",1};
SlashLibSavedData[43] = {"[界面]时钟信息","/clock",1};
SlashLibSavedData[44] = {"[界面]BUFF/DEBUFF显示增强","/buffalo config",1};
SlashLibSavedData[45] = {"[界面]BUFF增强","/ebb",1};
SlashLibSavedData[46] = {"[界面]信息追踪","/adf options",1};
SlashLibSavedData[47] = {"[团长工具]DKP记录系统","/rt",1};
SlashLibSavedData[48] = {"[团长工具]ROLL点助手","/lh",1};
SlashLibSavedData[49] = {"[团长工具]团队BUFF药剂检查","/rc",1};
SlashLibSavedData[50] = {"[团长工具]团队拾取监视","/lt",1};
SlashLibSavedData[51] = {"[团长工具]团队标记助手","/bb",1};
SlashLibSavedData[52] = {"[团长工具]团队标记助手","/srti",1};
SlashLibSavedData[53] = {"[团长工具]团队标记助手","/hmb",1};
SlashLibSavedData[54] = {"[团长工具]团队标记助手","/quickwark",1};
SlashLibSavedData[55] = {"[团长工具]团队自动邀请框架","/ai show",1};
SlashLibSavedData[56] = {"[团长工具]自动Debuff检查","/dlc",1};
SlashLibSavedData[57] = {"[团队]公会团队行事历","/calendar",1};
SlashLibSavedData[58] = {"[团队]NG团队框架","/ng",1};
SlashLibSavedData[59] = {"[团队]战斗数据统计","/sws",1};
SlashLibSavedData[60] = {"[团队]队伍查找器","/lft apam",1};
SlashLibSavedData[61] = {"[团队]KLHT仇恨监视","/ktm",1};
SlashLibSavedData[62] = {"[战斗]敌对施法条","/necb",1};
SlashLibSavedData[63] = {"[战斗]克苏恩预警","/ctw",1};
SlashLibSavedData[64] = {"[战斗]减益时间监视","/debufftimers",1};
SlashLibSavedData[65] = {"[战斗]战斗遭遇日志","/killlog",1};
SlashLibSavedData[66] = {"[战斗]增强伤害显示", "/dex",1};
SlashLibSavedData[67] = {"[战斗]暴击溅血特效" ,"/bs",1};
SlashLibSavedData[68] = {"[战斗]炸弹类技能报警", "/ekbowb",1};
SlashLibSavedData[69] = {"[战斗]触发法术和效果提示", "/powa",1};
SlashLibSavedData[70] = {"[战斗]战斗状态监视", "/StatusBars",1};
SlashLibSavedData[71] = {"[全职业]攻击间隔计时条" ,"/st",1};
SlashLibSavedData[72] = {"[全职业]消除施法延迟" ,"/fastcast",1};
SlashLibSavedData[73] = {"[全职业]自适应BUFF" ,"/bestbuff",1};
SlashLibSavedData[74] = {"[全职业]装备属性权重计算" ,"/bscan",1};
SlashLibSavedData[75] = {"[法师]自动交易-水和面包" ,"/VM show",1};
SlashLibSavedData[76] = {"[法师]自动售货机" ,"/td",1};
SlashLibSavedData[77] = {"[法师]保命助手-上盾" ,"/su help",1};
SlashLibSavedData[78] = {"[法师]冰环计时器" ,"/novawatch",1};
SlashLibSavedData[79] = {"[术士]DOT计时监视器" ,"/dot",1};
SlashLibSavedData[80] = {"[术士]术士拉人助手" ,"/caps",1};
SlashLibSavedData[81] = {"[术士/猎人]智能宠物" ,"/sp",1};
SlashLibSavedData[82] = {"[猎人]宠物喂食助手" ,"/pf",1};
SlashLibSavedData[83] = {"[猎人]射击条助手" ,"/yaht",1};
SlashLibSavedData[84] = {"[猎人]猎豹守护助手" ,"/ad options",1};
SlashLibSavedData[85] = {"[猎人]自动标记" ,"/automark",1};
SlashLibSavedData[86] = {"[战士]Buff封锁" ,"/bl",1};
SlashLibSavedData[87] = {"[战士]MT助手" ,"/tb",1};
SlashLibSavedData[88] = {"[战士]根据姿态切换武器" ,"/StanceSets",1};
SlashLibSavedData[89] = {"[圣骑士]祝福助手" ,"/palanoob",1};
SlashLibSavedData[90] = {"[圣骑士]祝福助手" ,"/pp",1};
SlashLibSavedData[91] = {"[圣骑士]祝福助手" ,"/gb",1};
SlashLibSavedData[92] = {"[萨满]图腾助手", "/coe",1};
SlashLibSavedData[93] = {"[萨满]图腾大师", "/at",1};
SlashLibSavedData[94] = {"[德鲁伊/盗贼]连击点/能量监视", "/ccb",1};
SlashLibSavedData[95] = {"[治疗]快速治疗" ,"/qh help",1};
SlashLibSavedData[96] = {"[治疗]祈福任务助手" ,"/PriestQuest",1};
-------------
TABLEVISBTNS = {};
SLIBLIGNE = {};
SLIBSCROLLHEIGHT = 22; -- hauteur ligne
SLIBVISLINE = 14; -- nombre de lignes visibles dans la main UI -- nombre de lignes visibles : SLIBVISLINE * SLIBSCROLLHEIGHT = hauteur ScrollFrame et aussi nombre de boutons-lignes
SLIBVISLINELIST = 22; -- nombre de lignes visibles dans la liste des slash-cmds
SLIBLISTALLCMDS = {};
local SEPLIGNE = "\n";
local enTest = false;

---------------------------------------------------------------------------------------
-------------------------- CHARGEMENT / COMMANDES /BINDINGS ---------------------------
function slibChargement()
	SlashCmdList["SLIBSHOWUI"] = slibUIShow;
		SLASH_SLIBSHOWUI1 = "/slashlib";
		SLASH_SLIBSHOWUI2 = "/cj";

	SlashCmdList["SLIBDOBTN"] = slibDoNomBtn;
		SLASH_SLIBDOBTN1 = "/slashlibdo";
		SLASH_SLIBDOBTN2 = "/slashlibexe";
		SLASH_SLIBDOBTN3 = "/slibdo";
		SLASH_SLIBDOBTN4 = "/slibexe";

	SlashCmdList["SLIBRESET"] = slibResetAll;
		SLASH_SLIBRESET1 = "/slibrao";
		SLASH_SLIBRESET2 = "/slashlibreset";

	SlashCmdList["SLIBHELP"] = slibHelpVers;
		SLASH_SLIBHELP1 = "/slashlibhelp";

	SlashCmdList["SLIBDEBUG"] = slibDebugOnOff;
		SLASH_SLIBDEBUG1 = "/slibdebug";

	SlashCmdList["SLIB_TEST"] = slibTest;
		SLASH_SLIB_TEST1 = "/slibx";

	-------------- bindings
	BINDING_HEADER_SLASHLIB = SLIB_NOM;
	BINDING_NAME_SLIBshow = "显示控制台";

	-------------- suite
	slibLigneInit();

	echo(SLIB_NOM.." "..SLIB_VERS.." 已载入 - 输入 /cj 查阅更多的帮助信息.","blue");
end

---------------------------------------------------------------------------------------
------------------------------------------ UI -----------------------------------------
function slibUIShow()
	if (SlibFrame:IsVisible()) then
		slibUIClose();
	else
		slibUIClose(); -- menage
		SlibFrame:Show(); -- ne pas intervertir avec la ligne suivante !
		slibScrollerUpdate(); -- ne pas intervertir avec la ligne precedente !
	end;
end

function slibScrollerUpdate()
	TABLEVISBTNS = {};
	local line; -- 1 through SLIBVISLINE
	local linePlusOffset; -- an index into our data calculated from the scroll offset
	local nbreLiMax = getn(SlashLibSavedData); -- nombre de lignes
	FauxScrollFrame_Update(SlibFrameScroller,nbreLiMax,SLIBVISLINE,SLIBSCROLLHEIGHT);
	if (enTest) then echo(SLIB_NOM.."---Scroll at "..FauxScrollFrame_GetOffset(SlibFrameScroller)); end;
	for line = 1,SLIBVISLINE,1 do
		linePlusOffset = line + FauxScrollFrame_GetOffset(SlibFrameScroller);
		if (linePlusOffset <= nbreLiMax) then
			TABLEVISBTNS[line] = SlashLibSavedData[linePlusOffset];
			TABLEVISBTNS[line][4] = linePlusOffset;
			getglobal("SlibFrameLine_"..line.."_BtnTitre_TxtTitre"):SetText(TABLEVISBTNS[line][1]);
			getglobal("SlibFrameLine_"..line.."_BtnCmd_Tex"):SetTexture(0.3,0.3,0.3,0.4);
			local genre = TABLEVISBTNS[line][3];
			if (genre == 2) then -- emote
				getglobal("SlibFrameLine_"..line.."_BtnTitre_TxtTitre"):SetTextColor(0.4,0.7,0.9);
			elseif (genre == 3) then -- macro
				getglobal("SlibFrameLine_"..line.."_BtnTitre_TxtTitre"):SetTextColor(0.9,0.4,0.4);
			else
				getglobal("SlibFrameLine_"..line.."_BtnTitre_TxtTitre"):SetTextColor(0.9,0.9,0.4);
			end;
			getglobal("SlibFrameLine_"..line.."_BtnCmd_TxtCmd"):SetText(string.gsub(SlashLibSavedData[linePlusOffset][2],SEPLIGNE,"..."));
			getglobal("SlibFrameLine_"..line):Show();
		else
			getglobal("SlibFrameLine_"..line):Hide();
		end;
	end;
	SlibFrameScroller:Show(); -- ???
end

function slibUIDo(nomBouton)
	slibGetLibLigne(nomBouton);
	if (SLIBLIGNE["cmd"] ~= "") then
		if (SlashLibSaved["closeRun"]) then SlibFrame:Hide(); end;
		slibDoSlashCmd(SLIBLIGNE["cmd"]);
	else
		echo(SLIB_NOM..": 错误 - 命令 #"..SLIBLIGNE["numLi"].." 不存在!","red");
	end;
end

function slibUINew()
	slibUIEditResetTex();
	SlibNameDef:SetText("");
	SlibCmdDef:SetText("");
	slibUIEditAllumeRadios(1); -- genre "slash-cmd" par defaut
	slibLigneInit();
	SlibEditFrame:Show();
	SlibNameDef:SetFocus();
end

function slibUIClose()
	SlibListCmdsFrame:Hide();
	SlibEditFrame:Hide();
	SlibNameDef:SetText("");
	SlibCmdDef:SetText("");
	SlibFrame:Hide();
end

function slibUIEdit(nomBouton)
	slibGetLibLigne(nomBouton);
	if (SLIBLIGNE["numLi"] > 0) then
		slibUIEditResetTex();
		getglobal("SlibFrameLine_"..SLIBLIGNE["numLi"].."_BtnCmd_Tex"):SetTexture(1,1,0,0.9);
		SlibNameDef:SetText(SLIBLIGNE["nom"]);
		SlibCmdDef:SetText(SLIBLIGNE["cmd"]);
		slibUIEditAllumeRadios(SLIBLIGNE["genre"]);
		SlibEditFrame:Show();
		SlibNameDef:SetFocus();
	end;
end

function slibUIEditResetTex()
	for i = 1,SLIBVISLINE,1 do
		getglobal("SlibFrameLine_"..i.."_BtnCmd_Tex"):SetTexture(0.3,0.3,0.3,0.4);
	end;
end

function slibUIEditSave()
	local nom = SlibNameDef:GetText();
	if (nom ~= "") then
		local commande = SlibCmdDef:GetText();
		local novoLigne = {nom,commande,slibUIEditGetNumRadio()};
		if (SLIBLIGNE["numLi"] == 0) then -- new
			if (enTest) then echo(SLIB_NOM.."----保存新命令行="..SLIBLIGNE["numLi"].."---NumRad="..slibUIEditGetNumRadio().."."); end;
			table.insert(SlashLibSavedData,novoLigne);
		else
			if (enTest) then echo(SLIB_NOM.."----保存编辑命令行="..SLIBLIGNE["numLi"].."---NumRad="..slibUIEditGetNumRadio().."."); end;
			SlashLibSavedData[SLIBLIGNE["numLiOr"]] = novoLigne;
		end;
		---------
		SlashLibSavedData = sortTable(SlashLibSavedData,1,"1","200");
		---------
		slibScrollerUpdate();
		slibUIEditResetTex();
		SlibListCmdsFrame:Hide();
		SlibEditFrame:Hide();
	else
		echo(SLIB_NOM..": 键入个名字，定义为这个新的命令行!","red");
	end;
end

function slibUIEditDelete(nomBouton)
	if (nomBouton ~= nil and nomBouton ~= "") then -- si appel depuis l'UI principale (clic liste)
		slibGetLibLigne(nomBouton);
	end;
	if (SLIBLIGNE["numLi"] > 0) then -- appel normal : btn "delete" UI edition
		if (enTest) then echo(SLIB_NOM..":编辑删除---SLIB[numLi]="..SLIBLIGNE["numLi"].."---SLIB[numLiOr]="..SLIBLIGNE["numLiOr"].."---"); end;
		table.remove(SlashLibSavedData,SLIBLIGNE["numLiOr"]);
		slibScrollerUpdate();
		SlibEditFrame:Hide();
	else
		echo(SLIB_NOM..": 空的不能删除!","red");
	end;
end

function slibUIEditCancel()
	SlibListCmdsFrame:Hide();
	SlibEditFrame:Hide();
	SlibNameDef:SetText("");
	SlibCmdDef:SetText("");
	slibUIEditResetTex();
	slibLigneInit(); -- secu
end

function slibUIEditAllumeRadios(numBtn)
	SlibRadBtn1:SetChecked(0);
	SlibRadBtn2:SetChecked(0);
	SlibRadBtn3:SetChecked(0);
	if (numBtn ~= nil and numBtn ~= "") then
		local nbre = strToNumber(numBtn);
		if (nbre > 1 and nbre <= 3) then
			getglobal("SlibRadBtn"..numBtn):SetChecked(1);
		else
			SlibRadBtn1:SetChecked(1);
		end;
	else
		echo(SLIB_NOM..": 错误 - 无效按钮!","red");
	end;
end

function slibUIEditGetNumRadio()
	local i;
	for i = 1,3,1 do
		if (getglobal("SlibRadBtn"..i):GetChecked() == 1) then return i; end;
	end;
	return 1; -- defaut
end

function slibUIEditListShow()
	if (SlibListCmdsFrame:IsVisible()) then
		SlibListCmdsFrame:Hide();
	else
		listeAllSlashCmd(); -- remplissage SLIBLISTALLCMDS
		SlibListCmdsFrame:Show(); -- ne pas intervertir avec la ligne suivante !
		slibScrollerListUpdate(); -- ne pas intervertir avec la ligne precedente !
	end;
end

function slibScrollerListUpdate()
	local line; -- 1 through nbreLiVis
	local linePlusOffset; -- an index into our data calculated from the scroll offset
	local nbreLiMax = getn(SLIBLISTALLCMDS); -- nombre de lignes
	FauxScrollFrame_Update(SlibListFrameScroller,nbreLiMax,SLIBVISLINELIST,SLIBSCROLLHEIGHT);
	if (enTest) then echo(SLIB_NOM.."---Scroll at "..FauxScrollFrame_GetOffset(SlibListFrameScroller)); end;
	for line = 1,SLIBVISLINELIST,1 do
		linePlusOffset = line + FauxScrollFrame_GetOffset(SlibListFrameScroller);
		if (linePlusOffset <= nbreLiMax) then
			getglobal("SlibListLigneBtn_"..line.."_Texte"):SetText(SLIBLISTALLCMDS[linePlusOffset]);
			getglobal("SlibListLigneBtn_"..line):Show();
		else
			getglobal("SlibListLigneBtn_"..line):Hide();
		end;
	end;
	SlibListFrameScroller:Show(); -- ???
end

function slibUIEditListClick(txtBouton)
	if (txtBouton ~= nil) then
		if (string.sub(txtBouton,1,1) == "/") then
			if (IsControlKeyDown()) then -- DO (TEST)
				SlibCmdDef:SetText(SlibCmdDef:GetText()..txtBouton);
			else -- AJOUT EDIT
				slibDoSlashCmd(txtBouton);
			end;
		else
			echo(SLIB_NOM..": 错误 - "..txtBouton.." 不是个有效命令行!","red");
		end;
	else
		echo(SLIB_NOM..": 错误 - 无效命令行(NIL)!","red");
	end;
end

---------------------------------------------------------------------------------------
------------------------------------ FCNS INTERNES ------------------------------------
function slibDoNomBtn(arg)
	if (arg ~= nil and arg ~= "") then
		local trouvePas = true;
		local nomSlash = string.upper(string.gsub(string.gsub(arg,"\"",""),"\'",""));
		for i = 1,getn(SlashLibSavedData),1 do
			if (string.upper(SlashLibSavedData[i][1]) == nomSlash) then
				trouvePas = false;
				slibDoSlashCmd(SlashLibSavedData[i][2]);
				break;
			end;
		end;
		if (trouvePas) then echo(SLIB_NOM..": 错误 - 无法找到脚本 "..nilSiNul(nomSlash).."!","red"); end;
	else
		echo(SLIB_NOM..": 错误 - 参数不能为空!","red");
	end;
end

function slibResetAll()
	SlashLibSaved = {};
	SlashLibSaved["closeRun"] = false;
	slibUIClose();
	slibUIShow();
	echo(SLIB_NOM..": 选项重置为默认值.","green");
end

function slibLigneInit()
	SLIBLIGNE = {};
	SLIBLIGNE["numLi"] = 0;
	SLIBLIGNE["nom"] = "";
	SLIBLIGNE["cmd"] = "";
	SLIBLIGNE["genre"] = 1; -- genre : 1 = slash-cmd, 2 = Emote et 3 = Macro
	SLIBLIGNE["numLiOr"] = 0;
end

function slibGetLibLigne(nomBouton)
	if (nomBouton ~= nil) then
		local numBtn = strToNumber(extractValeur(nomBouton,"_"));
		if (enTest) then echo(SLIB_NOM..":GETLIBLIGNE---BtnName="..nomBouton.."---LineNumber="..numBtn.."---"); end;
		if (numBtn > 0 and numBtn <= getn(TABLEVISBTNS)) then
			SLIBLIGNE["numLi"] = numBtn;
			SLIBLIGNE["nom"] = TABLEVISBTNS[numBtn][1];
			SLIBLIGNE["cmd"] = TABLEVISBTNS[numBtn][2];
			SLIBLIGNE["genre"] = TABLEVISBTNS[numBtn][3];
			SLIBLIGNE["numLiOr"] = TABLEVISBTNS[numBtn][4];
		else
			slibLigneInit();
			echo(SLIB_NOM..": 错误 - 无法找到 #"..nilSiNul(numBtn).."!","red");
		end;
	else
		slibLigneInit();
		echo(SLIB_NOM..": 错误 - 空行!","red");
	end;
end

function slibDoSlashCmd(chaineCmd)
	local chaine = chaineCmd..SEPLIGNE;
	local pos1,pos2,chaineTemp;
	local i = 1;
	while string.find(chaine,SEPLIGNE,1,true) ~= nil do
		pos1,pos2 = string.find(chaine,SEPLIGNE,1,true);
		chaineTemp = string.sub(chaine,1,pos1 - 1);
		if (enTest) then echo(SLIB_NOM.."---执行字串 "..i..":"..chaineTemp.."---"); end;
		-------- envoi ligne de commande
		if (string.sub(chaineTemp,1,1) == "/") then
			DEFAULT_CHAT_FRAME.editBox:SetText(chaineTemp);
			ChatEdit_SendText(DEFAULT_CHAT_FRAME.editBox,0);
		else
			echo(SLIB_NOM..": 错误 - "..chaineTemp.." 不是有效命令!","red");
		end;
		--------
		chaine = string.sub(chaine,pos2 + 1);
		i = i + 1;
		if (i > 50) then return; end; -- secu
	end;
end

function listeAllSlashCmd()
	SLIBLISTALLCMDS = {};
	local prevCommande = "";
	for index,value in pairs(SlashCmdList) do -- SlashCmdList = table Blizzard des slash-cmds
		local i = 1;
		local cmdString = TEXT(getglobal("SLASH_"..index..i));
		while (cmdString) do
			if (cmdString ~= prevCommande) then
				table.insert(SLIBLISTALLCMDS,cmdString);
				prevCommande = cmdString;
			end;
			i = i + 1;
			cmdString = TEXT(getglobal("SLASH_"..index..i));
		end;
	end;
	table.sort(SLIBLISTALLCMDS);
end

function slibHelpVers()
	echo(SLIB_NOM.." 版本 "..SLIB_VERS..".","blue");
	slibSlashListe();
end

function slibDebugOnOff()
	enTest = not enTest;
	echo(SLIB_NOM..": 除错 "..booleanToSr(enTest)..".","green");
end

function slibTest(arg)
	local chaine;
	if (SlashLibSavedData ~= nil and SlashLibSavedData ~= "" or getn(SlashLibSavedData) < 1) then
		for i = 1,getn(SlashLibSavedData),1 do
			chaine = nilSiNul(SlashLibSavedData[i][2]);	echo("保存数据:"..i.."---"..nilSiNul(SlashLibSavedData[i][1]).."---"..string.sub(string.gsub(chaine,SEPLIGNE,"..."),1,10).."---"..nilSiNul(SlashLibSavedData[i][3]).."---","green");
		end;
	else
		echo("保存数据: 为零或空!!!","red");
	end;
end

---------------------------------------------------------------------------------------
--排序（按照数字1-200排序）
function sortTable(tableOr,cle,sens,genre)
	local tableTemp = {};
	for i in ipairs(tableOr)do
		table.insert(tableTemp,i);
	end;
	if (sens == nil) then sens = "1"; end;
	sens = string.upper(string.sub(sens,1,1));
	if (genre == nil) then genre = "200"; end;
	genre = string.upper(string.sub(genre,1,1));
	for i in ipairs(tableTemp)do
		tableTemp[i] = tableOr[tableTemp[i]];
	end
	return tableTemp;
end

function extractValeur(chaine,sep)
	-- renvoit la portion de la chaine passee situee entre les 2 premiers sep (ou vide si sep n'est pas trouve)
	if (chaine ~= nil and sep ~= nil) then
		local pos = string.find(chaine,"_",1,true);
		if (pos ~= nil) then
			local chaineTemp = string.sub(chaine,pos + 1);
			pos = string.find(chaineTemp,"_",1,true);
			if (pos ~= nil) then
				return (string.sub(chaineTemp,1,pos - 1));
			else
				return chaineTemp;
			end;
		else
			return "";
		end;
	else
		return nil;
	end;
end

function strToNumber(chaine)
	local valeur = tonumber(string.gsub(string.gsub(chaine,"\"",""),"\'",""),10);
	if (valeur == nil) then valeur = 0; end;
	return valeur;
end

function booleanToSr(valeur)
	if (valeur) then return "true"; else return "false"; end;
end

function booleanToBin(valeur)
	return (valeur == 1);
end

function videSiNul(valeur)
	if (valeur == nil) then return ""; else return valeur; end;
end

function nilSiNul(valeur)
	if (valeur == nil) then return "NIL"; else return valeur; end;
end

function echo(chaine,nomCouleur)
	local coulr,coulg,coulb = 1,1,1 ; -- couleurs
	if (nomCouleur == "red") then
		coulr,coulg,coulb = 1,0,0;
	elseif (nomCouleur == "green") then
		coulr,coulg,coulb = 0,1,0;
	elseif (nomCouleur == "blue") then
		coulr,coulg,coulb = 0.5,0.5,0.8;
	elseif (nomCouleur == "orange") then
		coulr,coulg,coulb = 0.8,0.3,0.1;
	elseif (nomCouleur == "yellow") then
		coulr,coulg,coulb = 0.9,0.9,0.1;
	elseif (nomCouleur == "grey" or nomCouleur == "gray") then
		coulr,coulg,coulb = 0.6,0.6,0.6;
	end;
	if (DEFAULT_CHAT_FRAME) then DEFAULT_CHAT_FRAME:AddMessage(chaine,coulr,coulg,coulb); end;
end

------------------------------------- AIDE ONLINE -------------------------------------
function slibSlashListe()
	local i;
	local aideOnline =  {};
	aideOnline[1] = "/cj: 显示命令行";
	echo("------------------------","grey");
	for i = 1,getn(aideOnline),1 do
		echo("   "..aideOnline[i].."\n","grey");
	end;
	echo("------------------------","grey");
end

--聊天框创建"命令"按钮
local MySlashButton = CreateFrame("Button", "MySlashButton", ChatFrame)
SetSize(MySlashButton, 17, 17)
MySlashButton:SetNormalTexture("Interface\\AddOns\\MySlash\\UiLogo.tga")
MySlashButton:SetPushedTexture("Interface\\AddOns\\MySlash\\UiLogo.tga")
MySlashButton:GetPushedTexture():SetTexCoord(.09,.91,.09,.91)
MySlashButton:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight", "ADD")
MySlashButton:GetHighlightTexture():SetTexCoord(.09,.91,.09,.91)
MySlashButton:SetPoint("BOTTOMRIGHT", ChatFrame1, "TOPRIGHT", -22, 5)

MySlashButton:SetScript("OnMouseDown", function()
	if arg1 == "LeftButton" then
		PlaySound("igChatEmoteButton")
		slibUIShow()
		slibUIEditListShow()
	end	
end)

MySlashButton:SetScript("OnEnter", function() 
	GameTooltip:SetOwner(this, "ANCHOR_TOP", 0, 6)
	GameTooltip:AddLine("命令")
	GameTooltip:Show()
end)

MySlashButton:SetScript("OnLeave", function() GameTooltip:Hide() end)

EnableAutohide(MySlashButton, 0.5)